var mongoose=require('mongoose');
var Post=mongoose.model('Post',{
    title:String,
    author:String,
    read:{//阅读次数
        type:Number,
        default:0
    },
    comments:[{
        content:String,
        like:{//赞
            type:Number,
            default:0
        }
    }]
});
var db=mongoose.connect('mongodb://localhost/MongoDB_QuanWei_2');

(function () {
    new Post({
        title:'post 2',
        author:'a 2',
        comments:[
            {
                content:'c 21'
            },
            {
                content:'c 22'
            },
            {
                content:'c 23'
            }
        ]
    }).save((err,r)=>{
            console.log(err,r);
            process.exit(1);
    });
})();


